package com.ycw.controller.guoguo;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ycw.bean.Users;
import com.ycw.service.guoguo.UserRegistrationService;
import com.ycw.util.Msg;

/**
 * 用户表 注册
 * @author gcz
 *
 */
@Controller
public class UserRegistrationController {

	@Autowired
	private UserRegistrationService userRegistrationService;
	
	/**
	 * 用户Users表注册功能
	 * 邮箱唯一
	 * 没有找到邮箱，邮箱可以注册，并发送邮件，随机码存入session
	 * @param users 只存入邮箱
	 * @param httpSession
	 * @return Msg.code=200没有找到邮箱，邮箱可以注册
	 */
	@RequestMapping("getMailOnlyOne")
	@ResponseBody
	public Msg getMailOnlyOne(Users users, HttpSession httpSession){
		return userRegistrationService.getMailOnlyOne(users, httpSession);
	}
	
	/**
	 * 用户Users表注册功能
	 * 邮箱唯一
	 * 根据邮箱的随机码与session中的随机码比较如果相同
	 * @param users users内只有邮箱
	 * @param httpSession
	 * @return Msg.code=200随机码正确
	 */
	@RequestMapping("getUsCode")
	@ResponseBody
	public Msg getUsCode(Users users, HttpSession httpSession){
		return userRegistrationService.getUsCode(users, httpSession);
	}
	
	
	/**
	 * 用户身份证号不能重/用户手机号不能重
	 * 绝对不要同时存在身份证号和手机号
	 * @param users内只有身份证号或者只有手机号
	 * @return Msg.code=200数据不重
	 */
	@RequestMapping("getUsIdCardOrPhoneOnlyOne")
	@ResponseBody
	public Msg getUsIdCardOrPhoneOnlyOne(Users users){
		return userRegistrationService.getUsIdCardOrPhoneOnlyOne(users);
	}
	
	/**
	 * 添加用户信息
	 * @param users
	 * @return Msg.code=200添加成功
	 */
	@RequestMapping("addUsrs")
	@ResponseBody
	public Msg addUsrs(Users users){
		return userRegistrationService.addUsrs(users);
	}
	
}
